package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhPlatformUser;
import com.ruoyi.zsyh.service.IZsyhPlatformUserService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 平台客户档案Controller
 * 
 * @author yuexl
 * @date 2021-12-21
 */
@Controller
@RequestMapping("/zsyh/platformUser")
public class ZsyhPlatformUserController extends BaseController
{
    private String prefix = "zsyh/platformUser";

    @Autowired
    private IZsyhPlatformUserService zsyhPlatformUserService;

    @RequiresPermissions("zsyh:platformUser:view")
    @GetMapping()
    public String platformUser()
    {
        return prefix + "/platformUser";
    }

    @RequiresPermissions("zsyh:platformUser:view")
    @GetMapping("/messageView")
    public String messageView()
    {
        return prefix + "/messageView";
    }

    /**
     * 查询平台客户档案列表
     */
    @RequiresPermissions("zsyh:platformUser:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhPlatformUser zsyhPlatformUser)
    {
        startPage();
        List<ZsyhPlatformUser> list = zsyhPlatformUserService.selectZsyhPlatformUserList(zsyhPlatformUser);
        return getDataTable(list);
    }

    /**
     * 导出平台客户档案列表
     */
    @RequiresPermissions("zsyh:platformUser:export")
    @Log(title = "平台客户档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhPlatformUser zsyhPlatformUser)
    {
        List<ZsyhPlatformUser> list = zsyhPlatformUserService.selectZsyhPlatformUserList(zsyhPlatformUser);
        ExcelUtil<ZsyhPlatformUser> util = new ExcelUtil<ZsyhPlatformUser>(ZsyhPlatformUser.class);
        return util.exportExcel(list, "平台客户档案数据");
    }

    /**
     * 新增平台客户档案
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存平台客户档案
     */
    @RequiresPermissions("zsyh:platformUser:add")
    @Log(title = "平台客户档案", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhPlatformUser zsyhPlatformUser)
    {
        return toAjax(zsyhPlatformUserService.insertZsyhPlatformUser(zsyhPlatformUser));
    }

    /**
     * 修改平台客户档案
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhPlatformUser zsyhPlatformUser = zsyhPlatformUserService.selectZsyhPlatformUserById(id);
        mmap.put("zsyhPlatformUser", zsyhPlatformUser);
        return prefix + "/edit";
    }

    /**
     * 修改保存平台客户档案
     */
    @RequiresPermissions("zsyh:platformUser:edit")
    @Log(title = "平台客户档案", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhPlatformUser zsyhPlatformUser)
    {
        return toAjax(zsyhPlatformUserService.updateZsyhPlatformUser(zsyhPlatformUser));
    }

    /**
     * 删除平台客户档案
     */
    @RequiresPermissions("zsyh:platformUser:remove")
    @Log(title = "平台客户档案", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhPlatformUserService.deleteZsyhPlatformUserByIds(ids));
    }
}
